#define DEBUG
#include <cstdio>
#define MAXN 200000

using namespace std;

long long max(long long a, long long b) {
  return a>b ? a : b;
}

class Point {
public:
  int x, y;

  static bool cmp(Point *a, Point *b) {
    return a->x<b->x;
  }
};

template<class T>
void sort(T *a, int l, int r, bool cmp(T *a, T *b)) {
  int i=l, j=r;
  T mid=a[(l+r)/2], temp;
  for (; i<=j; ) {
    for (; cmp(&mid, a+j); j--);
    for (; cmp(a+i, &mid); i++);
    if (i<=j) {
      temp=a[i], a[i]=a[j], a[j]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sort(a, i, r, cmp);
  }
  if (j>l) {
    sort(a, l, j, cmp);
  }
}

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  static Point point[MAXN+1], liner[MAXN+1], linec[MAXN+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d %d", &point[i].x, &point[i].y);
    liner[point[i].y].x++;
    linec[point[i].x].x++;
  }
  for (int i=1; i<=n; i++) {
    liner[point[i].y].y+=linec[point[i].x].x-1;
    linec[point[i].x].y+=liner[point[i].y].x-1;
  }

  long long sum=0;
  for (int i=1; i<=n; i++) {
    sum += (liner[point[i].y].x-1)*(linec[point[i].x].x-1);
  }

  sort(point, 1, n, Point::cmp);
  sort(liner, 1, n, Point::cmp);
  
  static Point que[MAXN+1];
  int head=1, tail=0;
  for (int i=1; i<=n; i++) {
    if (liner[i].x || liner[i].y) {
      for (; (head<=tail && que[tail].x==liner[i].x) ? que[tail].y<=liner[i].y : head<tail && ((que[tail].y-liner[i].y)/(liner[i].x-que[tail].x)<(que[tail-1].y-liner[i].y)/(liner[i].x-que[tail-1].x)); tail--);
      que[++tail] = liner[i];
    }
  }

  long long ans=0;
  for (int i=1; i<=n; i++) {
    for (; head<tail && (que[head].y-que[head+1].y)/(que[head+1].x-que[head].x)<i; head++);
    ans = max(ans, que[head].x*linec[i].x+que[head].y+linec[i].y);
  }
  printf("%lld", ans+sum);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
